<template>
	<sc-table-select ref="tableselect" v-model="ticket" :attrList="attrList" :valueList="valueList"
		:queryList="queryList" :table-width="640" collapse-tags collapse-tags-tooltip :props="props" @change="change">
		<template #header="{ }">
			<el-form :inline="true">
				<el-row>
					<el-col :span="24">
						<el-form-item label="优惠券名称" label-width="100px">
							<el-input v-model="queryList.TicketName" placeholder="请输入优惠券名称"
								style="width: 120px"></el-input>
						</el-form-item>
						<el-form-item label="优惠券类型" label-width="100px">
							<el-select v-model="queryList.TypeCode" placeholder="请选择类型" style="width: 120px" clearable
								:teleported="false">
								<el-option v-for="item in optionsType" :key="item.value" :label="item.label"
									:value="item.value" />
							</el-select>
						</el-form-item>
						<el-button type="primary" @click="test" style="margin-top: -15px;">查询</el-button>
					</el-col>
				</el-row>
			</el-form>
		</template>
		<el-table-column prop="TicketCode" label="优惠券编码" width="150"></el-table-column>
		<el-table-column prop="TicketName" label="优惠券名称" width="230"></el-table-column>
		<el-table-column prop="TypeCodeName" label="类型" width="190"></el-table-column>
		<!-- <el-table-column prop="TicketNum" label="剩余数量" width="120"></el-table-column> -->
	</sc-table-select>
</template>

<script>
	import publicjs from "@/api/model/publicjs";
	export default {
		name: "scTicketChoice",
		props: {
			TicketClassType: {
				type: String,
				default: ""
			},
			OrgCode: {
				type: String,
				default: ""
			},
			BrandCode: {
				type: String,
				default: ""
			},
		},
		data() {
			return {
				attrList: {
					Name: "MemberCouponTicket",
					UseDistinct: false,
					OrgCode: "",
					UseBackUp: false,
					UseGroup: false,
					Batch: true
				},
				valueList: {
					OrgCode: "OrgCode",
					OrgName: "OrgName",
					TicketCode: "TicketCode",
					TicketName: "TicketName",
					TypeCode: "TypeCode",
					TicketAmt: "TicketAmt",
					TypeName: "TypeName",
					GoodsLimit: "GoodsLimit",
					UseConditionAmt: "UseConditionAmt",
					UseLimit: "UseLimit",
					UseAmt: "UseAmt",
					GrantCountLimit: "GrantCountLimit",
					CountLimit: "CountLimit",
					MaxCount: "MaxCount",
					UsefulDateType: "UsefulDateType",
					StartData: "StartData",
					EndData: "EndData",
					LimitDays: "LimitDays",
					UsefulWeek: "UsefulWeek",
					WeekStr: "WeekStr",
					UsefulTime: "UsefulTime",
					TimeStr: "TimeStr",
					LimitUseOneTime: "LimitUseOneTime",
					LimitUseOneDay: "LimitUseOneDay",
					TicketCoverType: "TicketCoverType",
					CoverFileUrl: "CoverFileUrl",
					Attachment: "Attachment",
					TicketState: "TicketState",
					IsUseByCondition: "IsUseByCondition",
					Discounts: "Discounts",
					GoodsCode: "GoodsCode",
					GoodsName: "GoodsName",
					GoodsCount: "GoodsCount",
					TicketPayType: "TicketPayType",
					BrandCode: "BrandCode",
					BrandName: "BrandName",
					Transfer: "Transfer",
					TransferCopywriting: "TransferCopywriting",
					TransferPic: "TransferPic",
					UseScene: "UseScene",
					IsUseNum: "",
					MemberUseDay: "MemberUseDay",
					MemberUseNum: "MemberUseNum",
					UseCondition: "UseCondition",
					RoomUseNum: "RoomUseNum",
					TicketClassType: "TicketClassType",
					TicketType: "TicketType",
					UomCode: "UomCode",
					GoodsLimit: "GoodsLimit",
					UseAmt: "UseAmt",
					PriceUseCondition: "PriceUseCondition",
					LineupUseScene:"LineupUseScene",
					IsDiscountSharing:"IsDiscountSharing"
				},
				queryList: {
					TicketState: "1",
					TicketType: "",
					TicketName: "",
					TicketClassType: this.TicketClassType,
					OrgCode: this.OrgCode,
					BrandCode: this.BrandCode
				},
				//apiObj: this.$API.demo.page,
				params: {
					name: "demoName",
				},
				optionsType: [],

			};
		},
		computed: {},
		watch: {
			TicketClassType(newvalue, oldvalue) {
				this.queryList.TicketClassType = newvalue;
			},
			OrgCode(newvalue, oldvalue) {
				this.queryList.OrgCode = newvalue;
			},
			BrandCode(newvalue, oldvalue) {
				this.queryList.BrandCode = newvalue;
			}
		},
		methods: {
			async test() {

				this.$refs.tableselect.getData();
			},
			async initOptions() {
				var head = new publicjs.head();
				publicjs.initHead(head, "getfirstdatasource");
				var ed1 = new publicjs.entitydata(head);
				var eo1 = new publicjs.entityobj();
				eo1.AttrList = {
					Name: "MemberCouponTicket",
					AcceptControl: "TypeCode",
					OrgCode: "",
				};
				ed1.Data.Content.ObjectList.Object.push(eo1);
				try {
					var returnValueStr1 = await this.$API.auth.objProcess.post(ed1);
					var returnValue1 = JSON.parse(returnValueStr1);
					if (returnValue1.Result.OpFlag == "1") {
						this.optionsType = returnValue1.Result.Content.ObjectList.Object.rows.row;
						// this.optionsOperType = objectList.rows.row;
					} else {
						this.$message.error("操作失败:" + returnValue1.Result.OpMsg);
					}
				} catch (error) {
					this.loading = false;
					this.$alert(error.message, "提示", {
						type: "error"
					});
					return false;
				}
			}
		},
		async mounted() {

			await this.initOptions();
			await this.test();
		},
	};
</script>

<style scoped></style>
